package cn.tinlan.shopcoin.app.mine.adress.adapter;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.tinlan.shopcoin.R;
import cn.tinlan.shopcoin.app.mine.adress.model.AddressItemModel;

/**
 * Created by Mortimer on 2018/12/19. 14:51
 * 佛祖🙏，永无bug。
 */
public class MultipleItemAdapter extends BaseQuickAdapter {

    private final int FOOT_TYPE = 1;
    private int mFootLayoutResId;
    List<AddressItemModel> addressItemModels;
    public MultipleItemAdapter(int layoutResId, int mFootLayoutResId,@Nullable List data) {
        super(layoutResId, data);
        this.mFootLayoutResId = mFootLayoutResId;
        addressItemModels = data;
    }

    @Override
    protected int getDefItemViewType(int position) {
        if (position == addressItemModels.size()) {
            return FOOT_TYPE;
        }
        return super.getDefItemViewType(position);
    }


    @Override
    public void setNewData(@Nullable List data) {
        super.setNewData(data);
        addressItemModels = data;
    }


    @Override
    protected BaseViewHolder onCreateDefViewHolder(ViewGroup parent, int viewType) {
        if (viewType == FOOT_TYPE) {
            return new FootViewHolder(getItemView(mFootLayoutResId,parent));
        }
        return super.onCreateDefViewHolder(parent, viewType);
    }

    @Override
    protected void convert(BaseViewHolder helper, Object item) {

    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {

        if (viewHolder instanceof FootViewHolder) {
//            ((FootViewHolder) viewHolder).foot.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    if (onAddressListFootClickListener != null) {
//                        onAddressListFootClickListener.OnAddressListFootClick();
//                    }
//                }
//            });
        }
    }


//    public interface OnAddressListFootClickListener {
//        public void OnAddressListFootClick();
//    }
//
//    private OnAddressListFootClickListener onAddressListFootClickListener;
//
//    public void setOnAddressListFootClickListener(OnAddressListFootClickListener onAddressListFootClickListener) {
//        this.onAddressListFootClickListener = onAddressListFootClickListener;
//    }

    public class FootViewHolder extends BaseViewHolder {

//        View foot;
        public FootViewHolder(View view) {
            super(view);
//            foot = view.findViewById(R.id.address_list_foot);
        }
    }
}
